<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<html xmlns:th="http://www.thymeleaf.org"> 

<head>
    <meta charset="UTF-8">
    <title></title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="description" content="Write an awesome description for your new site here. You can edit this line in _config.yml. It will appear in your document head meta (for Google search results) and in your feed.xml site description.">
    <link rel="stylesheet" href="lib/weui.min.css">
    <link rel="stylesheet" href="css/jquery-weui.css">
    <link rel="stylesheet" href="css/style.css">
</head>
<body>

    <form>
        <p><input id="inputprice" type="text" name="inputprice" class="form-control" th:value="${Allprice}" required></p>
        <p><input style="display: none"  id="orderId01" type="text" name="inputprice" class="form-control" th:value="${orderId}" required></p>
        <div><label>订单号：</label><span th:text="${orderId}"></span></div>
        <div><label>支付金额：</label><span th:text="${Allprice}"></span></div>
        <div>请选择支付方式</div>
        <div class="radio">
            <label>            
                <p><input type="radio" name="demo1" id="demo1-alipay" value="option1" checked="">
                    支付宝支付</p>
            </label>
        </div>
        <div class="radio">
            <label>
                <p><input type="radio" name="demo1" id="demo1-weixin" value="option2">
                微信支付</p>
            </label>
        </div>
        <button type="button" id="demoBtn1">确认购买</button>
        <a href="show_order.htm"></a>
    </form>



    <!--<form style='display:none;' id='formpay' name='formpay' method='post' action='https://pay.bbbapi.com/'>-->
        <form style='display:none;' id='formpay' name='formpay' method='post' action='https://pay.paysapi.com'>
        <input name='goodsname' id='goodsname' type='text' value='' />
        <input name='istype' id='istype' type='text' value='' />
        <input name='key' id='key' type='text' value=''/>
        <input name='notify_url' id='notify_url' type='text' value=''/>
        <input name='orderid' id='orderid' type='text' value=''/>
        <input name='orderuid' id='orderuid' type='text' value=''/>
        <input name='price' id='price' type='text' value=''/>
        <input name='return_url' id='return_url' type='text' value=''/>
        <input name='uid' id='uid' type='text' value=''/>
        <input type='submit' id='submitdemo1'>
    </form>

<!-- Jquery files -->
    <script src="lib/jquery-2.1.4.js"></script>
<script type="text/javascript">
jQuery(function(){
    function getistype(){
        return (jQuery("#demo1-alipay").is(':checked') ? "1" : "2" );
    }

    jQuery("#demoBtn1").click(function(){
        jQuery.post(
            "/pay",
            {
                price : jQuery("#inputprice").val(),
                orderId : jQuery("#orderId01").val(),
                istype : getistype(),

            },
            function(data){
                //alert(data.code);
                if (data.data.price > 0){
                    jQuery("#goodsname").val(data.data.goodsname);
                    jQuery("#istype").val(data.data.istype);
                    jQuery('#key').val(data.data.key);
                    jQuery('#notify_url').val(data.data.notify_url);
                    jQuery('#orderid').val(data.data.orderid);
                    jQuery('#orderuid').val(data.data.orderuid);
                    jQuery('#price').val(data.data.price);
                    jQuery('#return_url').val(data.data.return_url);
                    jQuery('#uid').val(data.data.uid);
                    jQuery('#submitdemo1').click();

                } else {
                    alert(data.msg);
                }
            }, "json"
        );
    });
});
</script>    


</body>
</html>